package com.breaktian.hybrid.webview;

import android.webkit.WebSettings;
import android.webkit.WebView;

import org.apache.cordova.engine.SystemWebView;
import org.apache.cordova.engine.SystemWebViewClient;

/**
 * Created by tiankeke on 2017/5/31.
 */

public class WebViewHelper {
    static void init(WebView webView) {
        WebSettings ws = webView.getSettings();
        //大小自适应
        ws.setUseWideViewPort(true);
        ws.setLoadWithOverviewMode(true);
        ws.setBuiltInZoomControls(true);
        ws.setSupportZoom(true);

        //js
        ws.setJavaScriptEnabled(true); // 设置支持javascript脚本
        ws.setJavaScriptCanOpenWindowsAutomatically(true);

        //see doc
        ws.setDomStorageEnabled(true);

        //cache
        String appCachePath = webView.getContext().getCacheDir().getAbsolutePath();
        ws.setAppCachePath(appCachePath);
        ws.setAppCacheEnabled(true);

        //file
        ws.setAllowFileAccess(true);

        //layout
        ws.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.NORMAL);

        //cache
        ws.setCacheMode(WebSettings.LOAD_CACHE_ELSE_NETWORK);

//        ws.setUserAgentString(ws.getUserAgentString() + USER_AGENT);
    }



}
